/**
 * Used to display wait for card prompt.
 * @author Steve
 */
package uicgas.register.GUI;

import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.EventQueue;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JProgressBar;
import javax.swing.SwingConstants;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;

public class ChargeCardWait extends JFrame
{

	private JPanel contentPane;
	private JProgressBar progressBar;

	/**
	 * Launch the application. used for testing
	 */
	public static void main(String[] args)
	{
		EventQueue.invokeLater(new Runnable()
		{
			public void run()
			{
				try
				{
					ChargeCardWait frame = new ChargeCardWait();
					frame.setVisible(true);
				}
				catch (Exception e)
				{
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame. and its components.
	 */
	@SuppressWarnings("deprecation")
	public ChargeCardWait()
	{
		setResizable(false);
		setTitle("UIC GAS - Processing Credit Card");
		setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		setCursor(Cursor.WAIT_CURSOR);
		setBounds(100, 100, 500, 500);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		progressBar = new JProgressBar(0,100);
		progressBar.setIndeterminate(true);
		progressBar.setBounds(5, 443, 474, 14);
		contentPane.add(progressBar);
		
		JLabel lblPlease = new JLabel("Please wait while the");
		lblPlease.setHorizontalAlignment(SwingConstants.CENTER);
		lblPlease.setFont(new Font("Tahoma", Font.BOLD, 30));
		lblPlease.setBounds(5, 161, 464, 37);
		contentPane.add(lblPlease);
		
		JLabel lblCustomersCreditcardIs = new JLabel("customers creditcard is");
		lblCustomersCreditcardIs.setFont(new Font("Tahoma", Font.BOLD, 30));
		lblCustomersCreditcardIs.setHorizontalAlignment(SwingConstants.CENTER);
		lblCustomersCreditcardIs.setBounds(5, 209, 464, 37);
		contentPane.add(lblCustomersCreditcardIs);
		
		JLabel lblProcessed = new JLabel("processed.");
		lblProcessed.setFont(new Font("Tahoma", Font.BOLD, 30));
		lblProcessed.setHorizontalAlignment(SwingConstants.CENTER);
		lblProcessed.setBounds(5, 257, 454, 37);
		contentPane.add(lblProcessed);
	}

	private void Pause(int iTimeInSeconds)
	{
		long time_start, time_end;

		time_start = System.currentTimeMillis();
		time_end = System.currentTimeMillis() + (iTimeInSeconds * 1000);

		do
		{
			time_start = System.currentTimeMillis();

		}
		while (time_start < time_end);
		{
			//do nothing, just wait
		}
	}
}
